package com.study.design.pattern.pattern.creational.builder;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.TimeUnit;

public class CacheTest {

    public static LoadingCache<String, String> cache;

    static {
        cache = CacheBuilder.newBuilder()
                .maximumSize(1000)
                .refreshAfterWrite(1, TimeUnit.MINUTES)
                .build(new CacheLoader<String, String>() {
                    @Override
                    public String load(String s) {
                        return "输出结果：" + s + "," + s;
                    }
                });
    }

    public static void main(String[] args) throws Exception {
        System.out.println(cache.get("cache"));
    }
}
